<!DOCTYPE html>
<html lang="en">
<head>
  <title>浩然金融中心管理平台</title>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"
        name="viewport">
  <#include "/common/csslib.html">
  <script type="text/javascript">
      var actRuTaskTable;
  </script>
</head>
<body>
<div class="main-wrapper">
  <!-- start: MAIN CONTAINER -->
  <div class="main-container inner">
    <!-- start: PAGE -->
    <div class="main-content">
      <div class="container">
        <!-- 当前位置 begin -->
        <div class="row h-home-path">
          <div class="col-md-12">
            <ol class="breadcrumb">
              <li><i class="fa fa-home"></i>&nbsp;&nbsp;所在位置</li>
              <li>首页</li>
              <li class="active">已发任务</li>
            </ol>
          </div>
        </div>
        <!-- 当前位置 end -->

        <!-- 查询筛选内容 bagin -->
        <div class="row h-main-search">
          <form action="javascript:;" method="post">
            <@PageDict dict_name="category" dict_desc="流程分类" dict_key="act_category" dict_value="" dict_type="select"
            page_type="index"/>
            <div class="pull-right h-btn-group">
              <button class="btn btn-info" onclick="ActRuTaskManager.search()" type="button"><i class="fa fa-search">&nbsp;&nbsp;</i>查询
              </button>
              <div id="btnPermission" style="display:none">
                <div class="h-btn-group">
                  <@permission btnType="view" btnLink="true" btnValue="查看详情" btnClass="btn btn-info" btnId="viewBtn"
                  op="act:task:view"/>
                  <@permission btnType="view" btnLink="true" btnValue="跟踪" btnClass="btn btn-info" btnId="followBtn"
                  op="act:task:follow"/>
                </div>
              </div>
              <button class="btn btn-default" type="reset"><i class="fa fa-mail-reply">&nbsp;&nbsp;</i>重置</button>
            </div>
          </form>
        </div>

        <!-- 表格 begin -->
        <div class="panel panel-white h-panel">
          <div class="panel-body">
            <table class="table table-striped table-bordered table-hover text-center" id="actRuTask_table"
                   style='width:100%'></table>
          </div>
        </div>
        <!-- 表格 end -->
      </div>
    </div>
    <!-- end: PAGE -->
  </div>
  <!-- end: MAIN CONTAINER -->
  <!-- 新增 end -->
  <!-- end: SUBVIEW SAMPLE CONTENTS -->
</div>
<#include "/common/jslib.html">

<script type="text/javascript">
    $(function () {
        ActRuTaskManager = {
            init: function () {

            },
            search: function () {
                var queryCond = {
                    category: $("#category").val()
                };
                actRuTaskTable.options.queryCond = queryCond;
                var tableId = actRuTaskTable.options.tableId;
                $(tableId).DataTable().draw();
            },
            viewTaskDetail: function (url) {
                Jmts.openDialog("viewTaskDetail", url, "查看详情", 0, 0, 32);
            },
            diagramViewer: function (url) {
                Jmts.openDialog("diagramViewer", url, "流程跟踪", 0, 0, 32);
            }
        }
        ActRuTaskManager.init();
    });
</script>
<!-- 弹窗下拉 -->
<script type="text/javascript">
    (function () {
        // datatable插件
        actRuTaskTable = new mi.datatable({
            tableId: '#actRuTask_table',
            headerList: [
                '流程编号',
                '流程标识',
                '流程名称',
                '流程版本',
                '流程状态',
                '开始时间',
                '操作'
            ],
            headerName: [
                'hisProcInsId',
                'procDefKey',
                'procDefname',
                'procDefversion',
                'processIsFinishedCn',
                'createTime',
                'operate'
            ],
            ajaxUrl: '/act/task/hasSentData',
            queryCond: function () {

            },
            columnDefs: [],
            paging: true,
            dataSrc: function (data) {
                for (var i in data) {
                    var id = data[i]['id'];
                    var procDefId = data[i]["procDefId"];
                    var procInsId = data[i]["procInsId"];
                    var taskId = data[i]["taskId"];
                    var taskName = data[i]["taskName"];
                    var taskDefKey = data[i]["taskDefKey"];
                    var status = data[i]["status"];
                    var processIsFinished = data[i]['processIsFinished'];
                    if ($("#viewBtn") != null && $("#viewBtn") != undefined) {
                        var url = "/act/task/form?taskId=" + taskId + "&taskName=" + taskName +
                            "&taskDefKey=" + taskDefKey + "&procInsId=" + procInsId + "&procDefId=" + procDefId + "&status=" + status;
                        $("#viewBtn").attr("href", "javascript:ActRuTaskManager.viewTaskDetail('" + url + "')");
                    }
                    if ($("#followBtn") != null && $("#followBtn") != undefined) {
                        var viewUrl = "";
                        if (processIsFinished == "finished") {
                            viewUrl = "/act/task/diagramViewer?definitionId=" + procDefId + "&hisInsId=" + procInsId;
                        } else {
                            viewUrl = "/act/task/diagramViewer?definitionId=" + procDefId + "&instanceId=" + procInsId;
                        }
                        $("#followBtn").attr("href", "javascript:ActRuTaskManager.diagramViewer('" + viewUrl + "')");
                    }

                    data[i]['operate'] = $("#btnPermission").html();
                    data[i]['procDefversion'] = "V:" + data[i]['procDefversion'];
                }
                return data;
            }
        });
    })();
</script>
</body>
</html>
